<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=s, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<style>
    .basic{
        width: 400px;
        height: 100px;
        border: 1px solid black;
    }

    .happy{
        border: 4px solid red;
        background-color: rgba(255, 255, 0, 0.644);
    }

    .sad{
        border: 4px dashed rgb(2, 197, 2);
        background-color: gray

    }

    .normal{
        background-color: skyblue;
    }

    .at1{
        background-color: yellowgreen;
    }

    .at2{
        font-size: 30px;
        text-shadow: 2px 2px 10px red;
    }

    .at3{
        border-radius: 20px;
    }
</style>
<body>
    <div id='root'>
        <!--绑定class样式，字符串写法-->
        <div  class="basic" :class='mod' @click='changemod'>test1</div>   
        <!--绑定class样式，数组写法-->
        <div  class="basic" :class='classarr'>test2</div> 
        <!--绑定style样式-->
        <div  class="basic" :style='styleObj'>test3</div> 
    </div>
    <script text="javascript">
        Vue.config.productionTip = false
        new Vue({
            el:'#root',
            data:{
                mod:'normal',
                classarr:['at1','at2','at3'],
                styleObj:{
                    fontSize:'60px',
                    color:'red',
                    backgroundColor:'orange'
                }
            },
            methods: {
                changemod(){
                    const arr=['happy','sad','normal']
                    const index = Math.floor(Math.random()*3)
                    this.mod=arr[index]
                }
            },
        })

    </script>
</body>
</html>